package com.gitee.xqlr.graphql.client.request.param;

import com.alibaba.fastjson.JSON;

import java.util.HashMap;
import java.util.Map;

/**
 * @author 杜文康
 * @version 1.0
 * @date 2019/8/13 15:18
 */
public class RequestPara extends HashMap<String, Object> {

    private RequestPara() {

    }

    public RequestPara addPara(String key, Object obj) {
        put(key, obj);
        return this;
    }

    public static RequestPara buildByMap(Map<String, Object> map) {
        RequestPara requestPara = build();
        requestPara.putAll(map);
        return requestPara;
    }

    public static RequestPara build() {
        return new RequestPara();
    }

    @Override
    public String toString() {
        if (size() == 0) {
            return "";
        }
        String tmp = JSON.toJSONString(this, 3088);
        return "(" + tmp.substring(1, tmp.length() - 1) + ")";
    }
}
